package xyz.robinbingo.effectivejava.chapter03.item14;

import cn.hutool.core.lang.Console;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.TreeSet;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author Robin
 * @date 2019/03/21 15:33
 **/
@RunWith(SpringRunner.class)
@SpringBootTest
public class Item14 {

    @Test
    public void test00() {
        BigDecimal a = new BigDecimal("1.0");
        BigDecimal b = new BigDecimal("1.00");
        Console.log(a.equals(b));
        Console.log(a.compareTo(b));
        HashSet<BigDecimal> hs = new HashSet<>();
        hs.add(a);
        hs.add(b);
        TreeSet<BigDecimal> ts = new TreeSet<>();
        ts.add(a);
        ts.add(b);
        Console.log(hs);
        Console.log(ts);
    }

    @Test
    public void test01() {
        SettleRange a = new SettleRange().setStart(new Date(100000));
        SettleRange b = new SettleRange().setStart(new Date(1000));
        SettleRange c = new SettleRange().setStart(new Date(1000000000));
        SettleRange d = new SettleRange().setStart(new Date(100000));
        SettleRange e = new SettleRange().setStart(new Date());
        TreeSet<SettleRange> collect = Stream.of(a, b, c, d, e).collect(Collectors.toCollection(TreeSet::new));
        Console.log(collect);
    }

}
